#include <stdio.h>
#include <stdlib.h>
#include <csp_spu.h>
#include <csp_debug.h>
#include "../fh_test.h"



int global_pid; 


int Run(){
	int pid = csp_pid();

	global_pid = csp_pid();

	int interval[2]  __attribute__ ((aligned(128)));
	interval[0] = 501;
	interval[1] = 2799;

	printf("Started init process (pid=%i) with interval [%i;%i]\n", 
		pid, interval[0], interval[1]);

	csp_channel init2farmer = 
		csp_create_channel(ONE2ONE_CHANNEL, INIT2FARMER, sizeof(int)*2);
	csp_channel_write(init2farmer, interval);


	csp_channel init2harvester = 
		csp_create_channel(ONE2ONE_CHANNEL, INIT2HARVESTER, sizeof(int)*2);
	csp_channel_write(init2harvester, interval);


	csp_channel init2verifier = 
		csp_create_channel(ONE2ONE_CHANNEL, INIT2VERIFIER, sizeof(int)*2);
	csp_channel_write(init2verifier, interval);

	ASSERT( pid == csp_pid() );
	ASSERT( global_pid == csp_pid() );

	PRINTF_FOR_TESTING("%s terminating on spe #%i with pid %i\n",__FILE__ , csp_spe_id(), pid);

	PRINTF_FOR_TESTING("Nested task with pid=%i terminated with res=%i.\n", pid, res);

	return 0;
}
